package cn.livingCloud.controller.user;

import cn.livingCloud.dto.SettingFromDto;
import cn.livingCloud.service.SettingService;
import cn.livingCloud.utils.SessionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by DingJie  on 2016/1/20.
 */
@Controller
@RequestMapping("/admin")
public class LoginController {
    @Autowired
    private SettingService settingService;

    @RequestMapping("/login.htm")
    public String login(Model model) {
        Object currentUserAccount = SessionUtils.getCurrentUserAccount();
        if (currentUserAccount != null) {
            return "redirect:index.htm";
        }

        SettingFromDto settingFromDto = settingService.loadFromDto();
        model.addAttribute("fromDto", settingFromDto);
        return "login";
    }
}
